<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link href="../../css/bootstrap.css" rel="stylesheet" />
<link href="../../css/cover.css" rel="stylesheet" />
<link href="../../css/font-awesome.min.css" rel="stylesheet" />
<title>荆州千网汇信息科技有限公司</title>
<script src="../../js/jquery-2.2.3.min.js"></script>
<script src="../../js/jquery.flexslider-min.js"></script>
<script src="../../js/rem.js"></script>
<script src="../../js/itnetcao.js"></script>
<link href="../../js/layui/css/layui.css" rel="stylesheet" />
<link href="../../js/donghua/animsition.min.css" rel="stylesheet" />
<script src="../../js/donghua/animsition.min.js"></script>
<link rel="stylesheet" href="../../css/minirefresh.css" />
<link rel="stylesheet" href="../../css/common.css" />
<script type="text/javascript" src="../../js/minirefresh.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/layui/layui.js"></script>
<title>我的账单</title>
<style type='text/css'>
#Show dt {
	margin: 0.5rem 0.1rem;
}

#Show dd p {
	margin: 0.1rem 0.1rem;
}

#Show dl img {
	border-radius: 50%;
	width: 1.5rem;
	height: 1.5rem;
}

#Show dl {
	margin-left: 0.2rem;
	display: flex;
}

#Show dl dd {
	margin-left: 0.5rem;
}

#Show button {
	height:0.5rem;
	line-height:0.28rem;
	border-radius: 0.2rem;
	outline-color: #FFFFFF;
	width: 2rem;
	color: #FFFFFF;
	background-color: #FFC90C;
}

.ShowName {
	font-size: 0.2rem;
}

.ShowOne {
	font-size: 0.2rem;
}

.ShowT {
	font-size: 0.2rem;
}

#ShowD {
	margin: 0.2rem;
}

#ShowP {
	margin: 0.2rem;
}
</style>
</head>
<body style='width:100%;height:100%;'>
	<div class="page_top01 relative">
        <h3 class="text-center">我的账单</h3>
        <a href="javascript:;" class="animsition-link" data-animsition-out-class="fade-out-right" data-animsition-out-duration="500" onclick="history.go(-1)">
            <img src="../../images/icon_left.png" class="img-responsive reture_img" /></a>
    </div>
    <div class='loadData'>

    </div>
<script type="text/javascript" src="../../js/clipboard.min.js"></script>
</body>

<script type='text/javascript'>
var options = {
	url : localStorage.getItem("url") + "/user/controller/UserOrderFindPageAPP.do",
	userId : jQuery.parseJSON(localStorage.getItem("miningmachine_user")).userId,
	data : "",
	pc : 1,
	ps : 1000,
	tr : null,
	tp : null,
	order : "",
	layer : null,
	init : function() {
		// 初始化
		var tis = this;

		layui.use("layer", function() {
			tis.layer = layui.layer;
		})

		tis.data = "userId=" + tis.userId;

		tis.loadUserBill();

		$(document).click(function(e) {
			var e = e || window.event;
			var target = e.target || e.srcElement;
			var targetName = target.nodeName.toLowerCase();
			// 显示用户的联系方式
			if($(target).is(".showWealth")) {
				var user_id = $(target).attr("data-id");

				var url = localStorage.getItem("url") + "/user/controller/UserPropertyAndUserInfoFindAllAPP.do";
				var data = "userId=" + user_id;

				itcao.itGetAjaxBigData(url, data).done(function(result) {

					var json = jQuery.parseJSON(result);
					if(json.state == true) {

						var bean = json.bean;

						if(bean.length == 0) {
							alert("获取用户的信息失败.");
							return;
						}

						var wx = -1;
						var zf = -1;

						for(var i=0; i<bean.length; i++) {
							if(bean[i].proType == 1) {
								zf = i;
							}
							if(bean[i].proType == 2) {
								wx = i;
							}
						}

						if(wx == -1 && zf == -1) {
							alert("用户还没有支付宝和微信信息,您可以拨打该用户的电话索取支付信息.");
						}


						var dianhua =
						"<div class='layui-col-xs12'>" +
							"<div class='layui-form-item'>" +
							    "<label class='layui-form-label'>电话</label>" +
							    "<div class='layui-input-inline'> " +
									"<input type='text' value='"+bean[0].userIphone+"' disabled class='layui-input dianhua_btn'>" +
							    "</div> " +
							    "<div class='layui-form-mid layui-word-aux btn_1'>点击复制</div>" +
							"</div>" +
						"</div> ";


						var wxhtml = "";

						if(wx != -1) {
							wxhtml =
							"<div class='layui-col-xs12'>" +
								"<div class='layui-form-item'>" +
								    "<label class='layui-form-label'>微信账号</label>" +
								    "<div class='layui-input-inline'> " +
										"<input type='text' value='"+bean[wx].proKey+"' disabled class='layui-input weixin_btn'>" +
								    "</div> " +
								    "<div class='layui-form-mid layui-word-aux btn_2'>点击复制</div>" +
								"</div>" +
							"</div> ";
						}
						var zfhtml = "";
						if(zf != -1) {
							zfhtml =
							"<div class='layui-col-xs12'>" +
								"<div class='layui-form-item'>" +
								    "<label class='layui-form-label'>支付账号</label>" +
								    "<div class='layui-input-inline'> " +
										"<input type='text' value='"+bean[zf].proKey+"' disabled class='layui-input zhifubao_btn'>" +
								    "</div> " +
								    "<div class='layui-form-mid layui-word-aux btn_3'>点击复制</div>" +
								"</div>" +
							"</div> ";
						}


						var html = "<div class='layui-fluid layui-form layui-form-pane' style='margin-top:20px;'>" +
							"<div class='layui-row layui-col-space15'>" +
								dianhua +
								wxhtml +
								zfhtml +
							"</div>" +
						"</div>"


						tis.layer.open({
							type : 1,
							content : html,
							area : ['80%', '60%'],
							title : false,
							success : function() {
								var clipboard_1 = new ClipboardJS('.btn_1', {
									text : function() {
										return $(".dianhua_btn").val();
									}
								});
								clipboard_1.on('success', function(e) {
								    alert("复制成功.");
								});
								clipboard_1.on('error', function(e) {
								    alert("非常抱歉,复制功能貌似出现了问题,您可以联系管理员解决.");
								});


								var clipboard_2 = new ClipboardJS('.btn_2', {
									text : function() {
										return $(".weixin_btn").val();
									}
								});
								clipboard_2.on('success', function(e) {
								    alert("复制成功.");
								});
								clipboard_2.on('error', function(e) {
								    alert("非常抱歉,复制功能貌似出现了问题,您可以联系管理员解决.");
								});

								var clipboard_3 = new ClipboardJS('.btn_3', {
									text : function() {
										return $(".zhifubao_btn").val();
									}
								});
								clipboard_3.on('success', function(e) {
								    alert("复制成功.");
								});
								clipboard_3.on('error', function(e) {
								    alert("非常抱歉,复制功能貌似出现了问题,您可以联系管理员解决.");
								});

							}
						})




					}else {
						alert("获取对方信息失败:" + json.value);
					}

				})

			}


			if($(target).is(".showWealth2")) {
				var buyId = $(target).attr("data-buyId");
				var buyUserId = $(target).attr("data-buyUserId");

				var url = localStorage.getItem("url") + "/buy/controller/UserIsBillSetState.do";
				var data = "op=confirmSell&billUserId=" + buyUserId + "&buyId=" + buyId;

				itcao.itGetAjaxBigData(url, data).done(function(result) {
					var json = jQuery.parseJSON(result);
					if(json.state == true) {
						alert("成功");
						tis.loadUserBill();
					}else {
						alert("失败:" + json.value);
						return false;
					}
				})
			}
		})



	},
	loadUserBill : function() {
		var tis = this;

		$(".loadData").empty();

		itcao.itGetAjaxBigData(tis.url, tis.data).done(function(result) {
			var json = jQuery.parseJSON(result);
			if(json.state == true) {
				for(var i=0; i<json.bean.length; i++) {
					var orderState = json.bean[i].orderState;
					var typeMsg = "";
					if(json.bean[i].orderState == 1) {
						typeMsg = "交易中";
					}
					if(json.bean[i].orderState == 2) {
						typeMsg = "交易完成";
					}
					if(json.bean[i].orderState == 4) {
						typeMsg = "买家已确认，待家卖确认";
					}
					if(orderState == 4) {
						$(".loadData").append(
							"<div id='Show' style='margin-top:20px;'>" +
								"<dl>" +
									"<dd id='ShowP' style='width:70%;'>" +
										"<p class='ShowOne'>XTS：<span id='ShowOneSpan'>"+json.bean[i].buyNumber+"</span></p>" +
										"<p class='ShowOne'>单价："+json.bean[i].buyPrice+"$</p>" +
										"<p class='ShowOne'>总价："+json.bean[i].buyTotalAmount+"$</p>" +
										"<p class='ShowOne'>CNY:" + json.bean[i].buyCny+"</p>" +
										"<p class='ShowOne'>时间:" + json.bean[i].orderDate+"</p>" +
									"</dd>" +
									"<dd id='ShowD'style='width:30%;'>" +
										"<p class='ShowT'>订单ID:"+json.bean[i].orderId+"</p>" +
										"<p class='ShowT'>"+typeMsg+"</p>" +
										"<p class='ShowT'><button style='width:80px;' data-buyUserId='"+json.bean[i].buyUserId+"' data-buyId='"+json.bean[i].buyId+"' class='btn btn-default showWealth2'>确认到账</button></p>" +
										"<p class='ShowT'><button style='width:80px;' data-id='"+json.bean[i].buyUserId+"' class='btn btn-default showWealth'>联系/付款</button></p>" +
										// "<p class='ShowT'><button style='width:80px;' data-id='"+json.bean[i].buyUserId+"' class='btn btn-default showPingZheng'>凭证</button></p>" +
									"</dd>" +
								"</dl>" +
								"<hr/>" +
							"</div>"
						);
					}

				}
			}

		})



	}
}
options.init();
</script>

</html>
